import java.util.Random;
import java.util.Scanner;

public class Protice06 {
    //定义一个长度为20的数组，元素为20-40的随机数，要求判断指定元素在数组中出现的次数，指定元素为键盘录入范围为20-40之间。
    public static void main(String[] args) {
        int[] num = new int[20];
        int count = 0;
        Random random = new Random();
        for (int i = 0; i < 20; i++) {
            num[i] = random.nextInt(21) + 20;
            System.out.print(num[i] + "\t");
        }
        System.out.println();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个20-40的数字：");
        int a = sc.nextInt() ;
        for (int i = 0; i < num.length; i++) {
            if (num[i] == a){
                count++;
            }
        }
        System.out.println("次数为"+count);
    }
}
